﻿using System.Collections.Generic;
using HqlIntellisense;
using Microsoft.VisualStudio.Language.Intellisense;
using Microsoft.VisualStudio.Text;

namespace HQLAddin.Intellisense
{
	public sealed class HqlCompletionRequestor : IHQLCompletionRequestor
	{
		private readonly ITrackingSpan applicableTo;
		private readonly IGlyphService glyphService;
		private readonly List<Completion> completions;

		public HqlCompletionRequestor(ITrackingSpan applicableTo, IGlyphService glyphService)
		{
			this.applicableTo = applicableTo;
			this.glyphService = glyphService;
			completions = new List<Completion>();
		}

		public CompletionSet CompletionSet
		{
			get
			{
				return new CompletionSet("Hql", "Hql", applicableTo, completions, null);
			}
		}

		public bool Accept(HQLCompletionProposal proposal)
		{
			var declaration = new HqlCompletion(proposal, glyphService);
			completions.Add(declaration);
			return true;
		}

		public void CompletionFailure(string errorMessage)
		{}
	}
}